<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<script src="../js/Width.js" type="text/javascript" charset="utf-8"></script>
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/register.css" />
		
		<style type="text/css">
			html,
			body {
				height: 100%;
			}
			
			body {
				background: url(../images/chengshi.png);
				background-size: cover;
				display: flex;
				justify-content: center;
				align-items: center;
			}
		</style>
	</head>

	<body>
		<div id="register">

			<div class="form">
              <span class="form-title">账号</span>
				<div class="mui-input-row bottom-underline">
					<input class="input" type="number" v-model="ipone"  @keyup.13="iphone($event)">
				</div>
				<span class="form-title">密码</span>
				<div class="mui-input-row mui-password bottom-underline">
					<input  class="input" type="password" v-model="Password" class="mui-input-password" @keyup.13="password($event)">
				</div>
			</div>

			<div class="margin-top20 botton" @click="tijiao">
				登录
			</div>
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/vue.js"></script>
		<script src="../js/util.js"></script>
		<script src="https://cdn.bootcss.com/fastclick/1.0.6/fastclick.min.js"></script>
		<script type="text/javascript">
			
			mui.init({
				keyEventBind: {
					backbutton: false //关闭back按键监听
				},
				swipeBack:false //启用右滑关闭功能
			})
			mui.plusReady(function() {
			
				if (!mui.os.android) {
					FastClick.attach(document.body);
				}
				
				var wv=plus.webview.currentWebview();
		        wv.setStyle({'popGesture':'none'});
		        // 获取客户端推送标识信息	
			    var info = plus.push.getClientInfo();
				var register = new Vue({
					el: '#register',
					data: {
						ipone: '',
						Password: ''
					},
					methods: {
						iphone: function(e) {

						},
						password: function(e) {

						},
						tijiao: function() {
							var that = this
							if(that.ipone){
							   if(!isPoneAvailable(that.ipone)){
							   	 mui.toast('请输入正确的手机号')
							   	 return
							   }
							}else{
								mui.toast('请填写账号')
							   	return
							}
							if(!that.Password){
								mui.toast('未输入密码')
								return
							}
							
                            mui.post(httpUrl.testUrl+'/api/Users/Login',{
									userName: that.ipone,
									userPwd: that.Password,
									CID:info.clientid
								},function(res){
									if(res.code==1001){
										var user = res.data
                                        var stand = user.stand.toString() 
										plus.storage.setItem('stand',stand)  // 用户 等级的判断指标  2 普通员工, 3 领班
										plus.storage.setItem('userID',user.userID) // 用户ID 用户身份的唯一指标
										mui.toast('登录成功')
									   setTimeout(function(){
											mui.back()
											var list = plus.webview.currentWebview().opener();
											//触发父页面的自定义事件(refresh),从而进行刷新
											mui.fire(list, 'refresh');
											//返回true,继续页面关闭逻辑
											return true;
//                                          mui.openWindow({
//												url: '../index.html',
//												id: 'index.html',
//												waiting: {
//													autoShow: false
//												}
//											});
										},1000)
				                       
									}else if(res.code==1002){
										mui.alert('账号或密码错误')
									}else{
										mui.alert('无效的参数')
									}
								}
							);
							
						}
					}
				})
			})
			
			         function isPoneAvailable (pone) {  
					   var myreg = /^[1][3,4,5,7,8][0-9]{9}$/;  
					   if (!myreg.test(pone)) {  
					     return false;  
					   } else {  
					     return true;  
					   }  
					 }
		</script>
	</body>
</html>